<template>
	<view>
		<view class="top">
			<uni-easyinput class="text" type="textarea" autoHeight v-model="addParams.content"
				placeholder="宝贝满足你的期待吗?说说你的使用心得，分享给想买的他们吧">
			</uni-easyinput>
		</view>

		<view class="bottom">
			<view class="go" @click="goComment">发布</view>
		</view>
	</view>
</template>

<script>
	export default {
		onLoad(e) {
			console.log(e);
			this.addParams.itemId = e.itemId;
		},
		data() {
			return {
				addParams: {
					content: "",
					itemId: ""
				}
			};
		},
		methods: {
			goComment() {
				if (this.addParams.content == "") {
					uni.showToast({
						title: "请输入评价内容",
						icon: 'error'
					})
					return;
				}
				let jwt = uni.getStorageSync('authority');
				uni.request({
					url: "api/appuser/addUserComment",
					data: this.addParams,
					method: 'POST',
					header: {
						"authority": jwt
					},
					success: (res) => {
						// console.log(res);
						if (res.data.code == 200) {
							uni.showToast({
								title: "发布成功",
								icon: 'success'
							})
							setTimeout(function() {
								uni.switchTab({
									url: "/pages/list/list",
								})
							}, 1500);
						}
					}
				})
			},
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #ededed;
	}

	.top {
		width: 700rpx;
		height: 300rpx;
		background-color: #fff;
		margin: 20rpx auto;
		margin-top: 50rpx;
		border-radius: 20rpx;

		.text {}
	}

	.bottom {
		width: 700rpx;
		height: 90rpx;
		// background-color: gray;
		margin: 0 auto;
		margin-top: 50rpx;

		.go {
			text-align: center;
			line-height: 90rpx;
			width: 100%;
			background-color: #fd4141;
			height: 100%;
			border-radius: 40rpx;
			color: #fff;
		}
	}
</style>